WorkerScript.onMessage = function(message) {
    doLoadMyCities(message);
}


function doLoadMyCities(message) {
    if (gMe == null) {
        message.model.clear();
        message.model.append({
                     cityName: "Please Login or Signup",
                     index: 0,
                     cityType: "placeholder"
        });
        message.model.sync();
        WorkerScript.sendMessage({ 'listState': '' })
        return;
    }
    var xhr = new XMLHttpRequest;
    var url = "https://production-2.sogeoapi.com/api/poi?per_page=" + message.g.perPage + "&oauth_token=" + message.token;
    xhr.open("GET", url);
    xhr.onreadystatechange = function() {
        if (xhr.readyState == XMLHttpRequest.DONE) {
            message.model.clear();
            var response = JSON.parse(xhr.responseText);
            console.log(xhr.responseText);
        }
        message.model.sync();
        WorkerScript.sendMessage({ 'listState': '' })
    }
    xhr.send();
}
